﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace PlusTween
{
    public static class PlusTweenTools
    {
        public static bool GetActive_NoPlusTween(GameObject gameObject)
        {
            if (null == gameObject) { Debug.LogError("gameObjectn is null !!!"); return false; }

            return gameObject.activeInHierarchy;
        }

        public static void SetActive_NoPlusTween(GameObject gameObject, bool isActive)
        {

            if (null == gameObject) { Debug.LogError("gameObjectn is null !!!"); return; }

            gameObject.SetActive(isActive);
        }

        public static PlusTweenBase SetActive(GameObject gameObject, bool isActive, bool isPlusTween = true)
        {
            if (null == gameObject) { Debug.Log("gameObject is null!!!"); return null; }

            PlusTweenBase[] plusTweenBases = gameObject.GetComponents<PlusTweenBase>();
            if (null == plusTweenBases || 0 == plusTweenBases.Length)
            {
                SetActive_NoPlusTween(gameObject, isActive);
                return null;
            }
            else
            {
                for (int i = 0, count = plusTweenBases.Length; i < count; i++)
                {
                    plusTweenBases[i].SetActive(isActive, isPlusTween);
                }
                var ret = plusTweenBases[0];
                return ret;
            }
        }

        public static bool GetActive( GameObject gameObject )
        {
            if (null == gameObject) { Debug.LogError("gameObjectn is null !!!"); return false; }

            return gameObject.activeInHierarchy;
        }

    }
}
